#ifndef _EVENTLOOPTHREADPOOL_H
#define _EVENTLOOPTHREADPOOL_H

#include "Channel.h"
#include "EventLoopThread.h"
#include "Logging.h"
#include "memory"
#include <memory>
#include <string>
#include <vector>
using namespace monsoon;

namespace droneswarm
{
    class EventLoopThreadPool
    {

    public:
        EventLoopThreadPool( EventLoop *baseLoop, int numThreads );
        ~EventLoopThreadPool();

        void start();

        EventLoop *getNextLoop();

    private:
        EventLoop *baseLoop_;                                        //主事件循环
        bool started_;                                               //标识线程池是否已经启动
        int numThreads_;                                             //标识线程池的线程数量
        int next_;                                                   //下一个要返回的事件循环的索引。
        std::vector< std::shared_ptr< EventLoopThread > > threads_;  //存放线程的线程池
        std::vector< EventLoop * > loops_;                           //存储事件循环的事件循环池

    private:
        EventLoopThreadPool( const EventLoopThreadPool & ) = delete;
        EventLoopThreadPool( const EventLoopThreadPool && ) = delete;
        EventLoopThreadPool &operator=( const EventLoopThreadPool & ) = delete;
    };
}  // namespace droneswarm
#endif